package sbpme.designer.parts;

import java.util.Observable;
import java.util.Observer;

import org.eclipse.gef.editparts.AbstractGraphicalEditPart;

public abstract class AbstractPart extends AbstractGraphicalEditPart implements Observer {

	private Observable getModelAsObservable() {
		return (Observable)getModel();
	}
	
	public void activate() {
		if (!isActive()) {
			getModelAsObservable().addObserver(this);
			super.activate();
		}
	}
	
	public void deactivate() {
		if (isActive()) {
			getModelAsObservable().deleteObserver(this);
			super.deactivate();
		}
	}
	
	public void update(Observable observable, Object argument) {
		refreshVisuals();
		refreshChildren();
		refreshSourceConnections();
		refreshTargetConnections();
	}
}
